<template>
  <div>
    <el-form ref="form" :model="form" label-width="150px"  style="width: 350px">
      <el-form-item label="vip价格(元)">
        <el-input v-model="form.type" maxlength="10" ></el-input>
      </el-form-item>
      <el-form-item label="通用医生价格(元)">
        <el-input v-model="form.doctorPrice" maxlength="10" ></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSubmit">提交</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
    export default {
        name: "updateVipPrice",
      data() {
        return {
          form: {
            type: '',
            price: '',
            doctorPrice: '',
            priceList: [],
          }
        }
      },
      methods: {
        onSubmit() {
          console.log('submit!');
          if(this.form.type==''){
            this.$message({
              message: '请填写完整的信息',
              type: 'warning'
            });
          }else {
            this.$ajax.post('http://47.75.110.31:8080/adinfo/updateVip?account=1&password='+this.form.type,
              {

                headers: {
                  'Content-Type': 'application/json;charset=UTF-8'
                }
              }
            ).then(response => {
              this.$ajax.post('http://47.75.110.31:8080/adinfo/updateVip?account=2&password='+this.form.doctorPrice,
                {

                  headers: {
                    'Content-Type': 'application/json;charset=UTF-8'
                  }
                }
              ).then(response => {
                console.log(response.data);
                if (response.data == "success") {
                  this.$message({
                    message: '恭喜你添加成功',
                    type: 'success'
                  });
                }
              })
            })
          }
        },
        getList(){
          this.$ajax.get('http://47.75.110.31:8080/adinfo/findByAccount?account=1')
            .then(response => {
              this.priceList = response.data;
              this.form.type = this.priceList[0].password;
              this.$ajax.get('http://47.75.110.31:8080/adinfo/findByAccount?account=2')
                .then(response => {
                  this.priceList = response.data;
                  this.form.doctorPrice = this.priceList[0].password;
                }).catch(function (err) {
                console.log(err)
              })
            }).catch(function (err) {
            console.log(err)
          })
        }
      },
      mounted() {
        this.getList();
      },
    }
</script>

<style scoped>

</style>
